
function setProduct(id, name) {
	$("#productId").val(id);
	var html = "<a href='" + context_path + "/product/viewProduct.do?id=" + id + "' target='_blank'> " + name + " </a>";
	$("#productName").html(html);
}
function submitProductSelect() {
	var id = $("#productId").val();
	if (id == null || id == "") {
		alert("\u8bf7\u9009\u62e9\u5546\u54c1!");
		return;
	}
	preTakePartInOrder(orderId, id);
}
function addNewProduct(categoryId) {
	var url = jtool.formatURLReffer(context_path + "/product/editProduct.do?categoryId=" + categoryId);
	jtool.open(url);
}
function showProductBox() {
	$("#productBox").show();
	$("#btnAddProduct").hide();
}
function hideProductBox() {
	$("#productBox").hide();
	$("#btnAddProduct").show();
}
function postNewProduct() {
	var target = context_path + "/product/saveProduct.do";
	var categoryId = $("#product_category_id").val();
	var name = $("#product_name").val();
	var introduction = $("#product_introduction").val();
	if (name == "") {
		alert("\u8bf7\u8f93\u5165\u5546\u54c1\u540d\u79f0!");
		return;
	}
	if (introduction == "") {
		alert("\u8bf7\u8f93\u5165\u5546\u54c1\u8bf4\u660e!");
		return;
	}
	var params = "product.category.id=" + categoryId;
	params += "&product.name=" + name;
	params += "&product.introduction=" + introduction;
	$.ajax({url:target, type:"POST", data:(params), success:function (content) {
		hideProductBox();
		document.location.reload();
	}});
}

